import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class DrawerDemo1 extends StatefulWidget {
  const DrawerDemo1({Key? key}) : super(key: key);

  @override
  _DrawerDemo1State createState() => _DrawerDemo1State();
}

class _DrawerDemo1State extends State<DrawerDemo1> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('drawer练习'),
        // leading: IconButton(
        //   icon: Icon(Icons.add),
        //   onPressed: () {},
        // ),
      ),
      body: Container(
        child: Text('222'),
      ),
      drawer: MyDrawer(),
    );
  }
}

class MyDrawer extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Drawer(
      child: MediaQuery.removePadding(
        //删除padding-貌似没有必要使用这个
        removeTop: true,
        context: context,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Padding(
              padding: EdgeInsets.only(top: 30),
              child: Text('2333'),
            )
          ],
        ),
      ),
    );
  }
}
